[アップデート] AWS Deploy Tool for .NET で自動作成される ECR リポジトリに自動でタグが付与されるようになりました

[アップデート] AWS Deploy Tool for .NET で自動作成される ECR リポジトリに自動でタグが付与されるようになりました

Clock Icon2024.07.16

いわさです。

AWS Deploy Tool for .NET は .NET CLI や AWS Toolkit for Visual Studio 向けのツールで、.NET CLI の延長的な使い方で簡単に .NET アプリケーションを AWS へデプロイすることが出来ます。

先日こちらのツールの新しいバージョンがリリースされ、いつものように眺めていました。

https://github.com/aws/aws-dotnet-deploy/releases/tag/1.21.13

すると、自動生成される ECR リポジトリにタグに自動で固定のタグが付与されるようになっているではありませんか。
誰が嬉しいんだこのアップデートはと言われそうですが、AWS Deploy Tool for .NET を使って自動テストなどを繰り返していると、いつのまにか不要な ECR リポジトリが大量に作成されていたりします。

今回 AWS Deploy Tool for .NET 経由で作成されるリポジトリに「aws-dotnet-deploy」というタグが付与されるようになったようです。
これを使って削除するリポジトリを識別したり、削除の自動化に利用することが出来そうです。

ツールをアップデートする

早速ツールをアップデートしてみましょう。
以下の README.md に従ってアップデートあるいは新規インストールを行います。

https://github.com/aws/aws-dotnet-deploy

% dotnet aws --version
AWS .NET deployment tool for deploying .NET Core applications to AWS.
Project Home: https://github.com/aws/aws-dotnet-deploy

1.1.15+5c57ebd489
% dotnet tool update -g aws.deploy.tools
Skipping NuGet package signature verification.
Tool 'aws.deploy.tools' was successfully updated from version '1.1.15' to version '1.21.13'.
% dotnet aws --version                  
AWS .NET deployment tool for deploying .NET Core applications to AWS.
Project Home: https://github.com/aws/aws-dotnet-deploy

Version: 1.21.13.0

最新バージョン 1.21.13 に更新することが出来ました。

デプロイしてみる

簡単なコンソールアプリを作成してデプロイしてみます。
この数ステップで ECR のクラスターやタスク、ECR リポジトリなど一瞬で作成出来るのいつ見てもすげえやという気持ちです。

% dotnet new console
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /Users/iwasa.takahito/work/hoge0716dotnet/hoge0716dotnet.csproj:
  Determining projects to restore...
  Restored /Users/iwasa.takahito/work/hoge0716dotnet/hoge0716dotnet.csproj (in 393 ms).
Restore succeeded.

% dotnet aws deploy
AWS .NET deployment tool for deploying .NET Core applications to AWS.
Project Home: https://github.com/aws/aws-dotnet-deploy

Configuring AWS Credentials using AWS SDK credential search.
Configuring AWS region using AWS SDK region search to ap-northeast-1.
Recommended Deployment Option
-----------------------------
1: Service on Amazon Elastic Container Service (ECS) using AWS Fargate
This .NET Console application will be built using a Dockerfile and deployed as a service to Amazon Elastic Container Service (Amazon ECS) with compute power managed by AWS Fargate compute engine. If your project does not contain a Dockerfile it will be automatically generated, otherwise an existing Dockerfile will be used. Recommended if you want to deploy a service as a container image on Linux.

Additional Deployment Options
------------------------------
2: Scheduled Task on Amazon Elastic Container Service (ECS) using AWS Fargate
This .NET Console application will be built using a Dockerfile and deployed as a scheduled task to Amazon Elastic Container Service (Amazon ECS) with compute power managed by AWS Fargate compute engine. If your project does not contain a Dockerfile it will be automatically generated, otherwise an existing Dockerfile will be used. Recommended if you want to deploy a scheduled task as a container image on Linux.

Choose deployment option (recommended default: 1)

Name the Cloud Application to deploy your project to
--------------------------------------------------------------------------------
Enter the name of the new CloudFormationStack stack (default hoge0716dotnet): 

Current settings (select number to change its value)
----------------------------------------------------
1. ECS Cluster: hoge0716dotnet
2. ECS Service Name: hoge0716dotnet-service
3. Desired Task Count: 1
4. Application IAM Role: *** Create new ***
5. Virtual Private Cloud (VPC): *** Default ***
6. Environment Variables: 
7. ECR Repository Name: hoge0716dotnet

Enter 'more' to display Advanced settings. 
Or press 'Enter' to deploy:
:

ECR リポジトリのタグを確認してみる

普段 ECR リポジトリタグってあまり使ったことがなかったのですが、リポジトリを選択してアクションメニューの「リポジトリタグ」から確認することができました 。

550497C8-EC05-4B14-9136-67D74B7B3772

確認してみると「aws-dotnet-deploy: ConsoleAppEcrFargateService」が付与されていました。
AWS Deploy Tool for .NET で選択するサービス構成によって値が変わりそうですが、キーは固定です。

05B2C101-209B-457B-8D35-F42524DD10FC_4_5005_c

さいごに

本日は AWS Deploy Tool for .NET で自動作成される ECR リポジトリに自動でタグが付与されるようになったので早速確認してみました。

今後はタグを利用して ECR リポジトリの整理が捗りそうです。

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.